/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package utilities;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import utilities.entities.RatedColumn;
import utilities.entities.Result;
import utilities.entities.Result.CResult;
import utilities.entities.Result.NResult;

/**
 *
 * @author olawale
 */
public class ResultFixture {

    public DefaultTableModel dtm;
    public TableColumnModel tcm; 
    public Result result;
    public ArrayList<Integer> cList;
    public ArrayList<Integer> hcList;
    private int rowNumber;
    private ArrayList<RatedColumn> columnList;

    private static SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy");


    public ResultFixture(Result result, DefaultTableModel tm, int row){
        this.result = result;
        dtm = tm;
        rowNumber = row;
        cList = new ArrayList();
        hcList = new ArrayList();
        columnList = new ArrayList();
    }


    public void fillData(){

//
//        try{
//            add("", null);
//        }catch(Exception ex){add("", ""); System.out.println("- " + ex);}
        
        try{
            add("1", result.aResult.arange.getName());
        }catch(Exception ex){
            add("1","");System.out.println("-1 " + ex);
        }

        try{
            add("2", result.aResult.arange.range());
        }catch(Exception ex){add("2","");System.out.println("-2 " + ex);}

        try{
            add("3A", result.aResult.rmatch.getScores());
        }catch(Exception ex){add("3A","");System.out.println("-3A " + ex);}

//        try{
//            add("3B", result.aResult.pmatch.getFixture());
//        }catch(Exception ex){add("3B","");System.out.println("-3B " + ex);}
//
//        try{
//            add("3C", Utility.f_subract(result.aResult.pmatch, result));
//        }catch(Exception ex){add("3C","");System.out.println("-3C " + ex);}
//
//        try{
//            add("3D", Utility.f_subract(result.uResult.matches.get(0), result));
//        }catch(Exception ex){add("3D","");System.out.println("-3D " + ex);}
//
//        try{
//            add("3E", Utility.f_subract(result.uResult.matches.get(1), result));
//        }catch(Exception ex){add("3E","");System.out.println("-3E " + ex);}
//
//        try{
//            add("3F", Utility.f_subract(result.uResult.matches.get(2), result));
//        }catch(Exception ex){add("3F","");System.out.println("-3F " + ex);}
//
//        try{
//            add("3G", Utility.f_subract(result.uResult.matches.get(3), result));
//        }catch(Exception ex){add("3G","");System.out.println("-3G " + ex);}
//
//        try{
//            add("3H", Utility.f_subract(result.uResult.matches.get(4), result));
//        }catch(Exception ex){add("3H","");System.out.println("-3H " + ex);}
//
//        try{
//            add("3I", result.aResult.resultRow.subList(2, 4).toArray(), new String[]{"A", "B"});
//        }catch(Exception ex){add("3I","");System.out.println("-3I " + ex);}

        try{
            add("4A", result.aResult.rmatch);
        }catch(Exception ex){add("4A","");System.out.println("4 " + ex);}

        try{
            add("5A", result.aResult.rmatch.getMatchDate());
        }catch(Exception ex){add("5A","");System.out.println("5A " + ex);}

//        try{
//            add("5B", result.aResult.rmatch.getMatchDate());
//        }catch(Exception ex){add("5B","");System.out.println("-5B " + ex);}

//        try{
//            add("6A", result.aResult.resultRow.get(0));
//        }catch(Exception ex){add("6A","");System.out.println("-6A " + ex);}
//
//        try{
//            add("6B", result.dCalendar.getDate(Integer.parseInt(result.aResult.resultRow.get(0).toString())));
//        }catch(Exception ex){add("6B","");System.out.println("-6B " + ex);}
//
//        try{
//            String d = result.dCalendar.getDate(Integer.parseInt(result.aResult.resultRow.get(0).toString()));
//            add("6C", MatchBean.getMatches(Utility.parseDate(d),
//                    result.aResult.rmatch.getFixture()).get(0).getScores());
//        }catch(Exception ex){add("6C","");System.out.println("-6C " + ex);}
//
//        try{
//            add("6D", Utility.f_subract(result.aResult.rmatch, result));
//        }catch(Exception ex){add("6D","");System.out.println("-6D " + ex);}
//
//        try{
//            add("6E", Utility.f_subract(result.aResult.rmatch, result));
//        }catch(Exception ex){add("6E","");System.out.println("-6E " + ex);}

//        try{
//            add("7", result.aResult.defaultRow.get(0));
//        }catch(Exception ex){add("7","");System.out.println("-7 " + ex);}

        try{
            add("8A", result.aResult.rmatch.getFixture());
        }catch(Exception ex){add("8A","");System.out.println("-8A " + ex);}

//        try{
//            add("8B", result.aResult.resultRow.subList(2, 4).toArray(), new String[]{"A", "B"});
//        }catch(Exception ex){add("8B","");System.out.println("-8B " + ex);}

        try{
            add("9A", result.aResult.resultRow.subList(2, 4).toArray(), new String[]{"A", "B"});
        }catch(Exception ex){add("9A","");System.out.println("-9A " + ex);}

//        try{
//            add("9B", result.aResult.resultRow.subList(2, 4).toArray(), new String[]{"A", "B"});
//        }catch(Exception ex){add("9B","");System.out.println("-9B " + ex);}

        try{
            add("10A", result.aResult.defaultRow.subList(2, 4).toArray(), new String[]{"A", "B"});
        }catch(Exception ex){add("10A","");System.out.println("-10A " + ex);}

//        try{
//            add("10B", "");
//        }catch(Exception ex){add("10B","");System.out.println("-10B " + ex);} //ambigous

//        try{
//            add("11A1", result.aResult.rmatch.getFixture());
//        }catch(Exception ex){add("11A1","");System.out.println("-11A1 " + ex);}
//
//        try{
//            add("11A2", Utility.f_subract(result.aResult.rmatch, result));
//        }catch(Exception ex){add("11A2", ""); System.out.println("-11A2 " + ex);}
//
//        try{
//            add("11A3", Utility.f_added(result.aResult.rmatch, result));
//        }catch(Exception ex){add("11A3", ""); System.out.println("-11A3 " + ex);}

        try{
            add("11A4", Utility.f_subract(result.aResult.rmatch, result));
        }catch(Exception ex){add("11A4", ""); System.out.println("-11A4 " + ex);}

        try{
            add("11A5", Utility.f_subract(result.aResult.rmatch, result));
        }catch(Exception ex){add("11A5", ""); System.out.println("-11A5 " + ex);}

//        try{
//            add("11A6", Utility.f_subract(result.aResult.rmatch, result));
//        }catch(Exception ex){add("11A6", ""); System.out.println("-11A6 " + ex);}
//
//        try{
//            add("11A7", Utility.f_subract(result.aResult.rmatch, result));
//        }catch(Exception ex){add("11A7", ""); System.out.println("-11A7 " + ex);}

        try{
            add("11B1", Utility.b_added(result.aResult.pmatch));
        }catch(Exception ex){add("11B1", ""); System.out.println("-11B1 " + ex);}

        try{
            add("11B2", result.aResult.pmatch);
        }catch(Exception ex){add("11B2", ""); System.out.println("-11B2 " + ex);}

        try{
            add("11B3", result.aResult.resultRow.subList(2, 4).toArray(), new String[]{"A","B"});
        }catch(Exception ex){add("11B3", ""); System.out.println("-11B3 " + ex);}

        try{
            add("11B4", result.aResult.resultRow.subList(2, 4).toArray(), new String[]{"A","B"});
        }catch(Exception ex){add("11B4", ""); System.out.println("-11B4 " + ex);}

        try{
            add("11B5", result.aResult.pmatch.getFixture());
        }catch(Exception ex){add("11B5", ""); System.out.println("-11B5 " + ex);}

        try{
            add("11B6", result.aResult.pmatch);
        }catch(Exception ex){add("11B6", ""); System.out.println("-11B6 " + ex);}

        try{
            add("11B7", result.pCalendar.getMonitors(result.aResult.pmatch.getMatchDate()),
                    new String[]{"A","B"});
        }catch(Exception ex){add("11B7", ""); System.out.println("-11B7 " + ex);}

        try{
            add("11B8", result.dCalendar.getMonitors(result.aResult.pmatch.getMatchDate()),
                    new String[]{"A","B"});
        }catch(Exception ex){add("11B8", ""); System.out.println("-11B8 " + ex);}

//        try{
//            add("11B9", Utility.b_added(result.aResult.pmatch));
//        }catch(Exception ex){add("11B9", ""); System.out.println("-11B9 " + ex);}
//
//        try{
//            add("11B10", result.aResult.pmatch);
//        }catch(Exception ex){add("11B10", ""); System.out.println("-11B10 " + ex);}

        try{
            add("11B11", result.dCalendar.getMonitors(result.bResult.cdate),
                    new String[]{"A","B"});
        }catch(Exception ex){add("11B11", ""); System.out.println("-11B11 " + ex);}

        try{
            add("11B12", result.aResult.pmatch.getScores());
        }catch(Exception ex){add("11B12", ""); System.out.println("-11B12 " + ex);}

        try{
            add("11B13", result.aResult.pmatch);
        }catch(Exception ex){add("11B13", ""); System.out.println("-11B13 " + ex);}

        try{
            add("11B14", result.dCalendar.getMonitors(result.bResult.cdate));
        }catch(Exception ex){add("11B14", ""); System.out.println("-11B14 " + ex);}

        try{
            add("11B15", Utility.b_added(result.aResult.pmatch));
        }catch(Exception ex){add("11B15", ""); System.out.println("-11B15 " + ex);}

        try{
            add("11B16", result.aResult.pmatch);
        }catch(Exception ex){add("11B16", ""); System.out.println("-11B16 " + ex);}

        try{
            add("11B17", result.aResult.resultRow.subList(2, 4).toArray(), new String[]{"A","B"});
        }catch(Exception ex){add("11B17", ""); System.out.println("-11B17 " + ex);}

        try{
            add("11B18", result.aResult.resultRow.subList(2, 4).toArray(), new String[]{"A","B"});
        }catch(Exception ex){add("11B18", ""); System.out.println("-11B18 " + ex);}

        try{
            add("11B19", result.aResult.pmatch.getFixture());
        }catch(Exception ex){add("11B19", ""); System.out.println("-11B19 " + ex);}

        try{
            add("11B20", result.aResult.pmatch);
        }catch(Exception ex){add("11B20", ""); System.out.println("-11B20 " + ex);}

        try{
            add("11B21", result.pCalendar.getMonitors(result.aResult.pmatch.getMatchDate()),
                    new String[]{"A","B"});
        }catch(Exception ex){add("11B21", ""); System.out.println("-11B21 " + ex);}

        try{
            add("11B22", result.dCalendar.getMonitors(result.aResult.pmatch.getMatchDate()),
                    new String[]{"A","B"});
        }catch(Exception ex){add("11B22", ""); System.out.println("-11B22 " + ex);}

        try{
            add("11B23", Utility.b_added(result.aResult.pmatch));
        }catch(Exception ex){add("11B23", ""); System.out.println("-11B23 " + ex);}

        try{
            add("11B24", result.aResult.pmatch);
        }catch(Exception ex){add("11B24", ""); System.out.println("-11B24 " + ex);}

        try{
            add("11B25", result.dCalendar.getMonitors(result.bResult.cdate),
                    new String[]{"A","B"});
        }catch(Exception ex){add("11B25", ""); System.out.println("-11B25 " + ex);}

        try{
            add("11B26", result.aResult.pmatch.getScores());
        }catch(Exception ex){add("11B26", ""); System.out.println("-11B26 " + ex);}

        try{
            add("11B27", result.aResult.pmatch);
        }catch(Exception ex){add("11B27", ""); System.out.println("-11B27 " + ex);}

        try{
            add("11B28", result.dCalendar.getMonitors(result.bResult.cdate));
        }catch(Exception ex){add("11B128", ""); System.out.println("-11B28 " + ex);}
        
//        try{
//            add("12", result.aResult.rowMatching.colVal.keySet().toArray());
//        }catch(Exception ex){add("12","");System.out.println("-12 " + ex);}
//
//        try{
//            add("13", result.aResult.rowMatching.colVal.values().toArray());
//        }catch(Exception ex){add("13","");System.out.println("-13 " + ex);}

        try{
            add("14", result.aResult.rowMatching.colVal.size());
        }catch(Exception ex){add("14","");System.out.println("-14 " + ex);}

        ArrayList<CResult> acr = null;
        try{
            acr = (ArrayList<CResult>) result.acResults;
        }catch(Exception ex){}
        ArrayList<String> scores = new ArrayList();
        try{
            scores.clear();
            for(CResult cr : acr)
                scores.add(cr.match.getScores());
            add("15", scores.toArray());
        }catch(Exception ex){add("15","");System.out.println("-15 " + ex);}

        try{
            scores.clear();
            for(CResult cr : acr)
                scores.add(cr.match.toString());
            add("16", scores.toArray());
        }catch(Exception ex){add("16","");System.out.println("-16 " + ex);}

        try{
            scores.clear();
            for(CResult cr : acr)
                scores.add(sdf.format(cr.match.getMatchDate()));
            add("17", scores.toArray());
        }catch(Exception ex){add("17","");System.out.println("-17 " + ex);}

        try{
            scores.clear();
            for(CResult cr : acr)
                scores.add(result.aResult.calander.getSerial(cr.match.getMatchDate()));
            add("18", scores.toArray());
        }catch(Exception ex){add("18","");System.out.println("-18 " + ex);}

//        try{
//            scores.clear();
//            for(CResult cr : acr)
//                scores.add(result.dCalendar.getSerial(cr.match.getMatchDate()));
//            add("19", scores.toArray(), new String[]{""}, true);
//        }catch(Exception ex){add("19","");System.out.println("-19 " + ex);}

        try{
            scores.clear();
            for(CResult cr : acr)
                scores.add(result.aResult.calander.getMonitors(cr.match.getMatchDate())[0] +
                " " + result.aResult.calander.getMonitors(cr.match.getMatchDate())[1]);
            add("20", scores.toArray());
        }catch(Exception ex){add("20","");System.out.println("-20 " + ex);}

        try{
            scores.clear();
            for(CResult cr : acr)
                scores.add(result.dCalendar.getMonitors(cr.match.getMatchDate())[0] +
                " " + result.dCalendar.getMonitors(cr.match.getMatchDate())[1]);
            add("21", scores.toArray());
        }catch(Exception ex){add("21","");System.out.println("-21 " + ex);}

//        try{
//            add("22A", Utility.f_subract(result.aResult.pmatch, result));
//        }catch(Exception ex){add("22A", ""); System.out.println("-22A " + ex);}
//
//        try{
//            add("22B", Utility.f_subract(result.aResult.pmatch, result));
//        }catch(Exception ex){add("22B", ""); System.out.println("-22B " + ex);}

        try{
            add("22C", Utility.f_subract(result.aResult.pmatch, result));
        }catch(Exception ex){add("22C", ""); System.out.println("-22C " + ex);}

        try{
            add("22D", Utility.f_subract(result.aResult.pmatch, result));
        }catch(Exception ex){add("22D", ""); System.out.println("-22D " + ex);}

        ArrayList<NResult> addL = null;
        try{
            addL = (ArrayList<NResult>) result.addResult;
        }catch(Exception ex){}
        try{
            scores.clear();
            for(NResult cr : addL)
                scores.add(cr.number + "");
            add("23", scores.toArray());
        }catch(Exception ex){add("23", ""); System.out.println("-23 " + ex);}

        try{
            scores.clear();
            for(NResult cr : addL)
                scores.add(sdf.format(cr.rMatch.getMatchDate()));
            add("24", scores.toArray());
        }catch(Exception ex){add("24", ""); System.out.println("-24 " + ex);}

//        try{
//            scores.clear();
//            for(NResult cr : addL)
//                scores.add(result.aResult.calander.getSerial(cr.rMatch.getMatchDate()));
//            add("25", scores.toArray(), new String[]{""}, true);
//        }catch(Exception ex){add("25", ""); System.out.println("-25 " + ex);}
//
//        try{
//            scores.clear();
//            for(NResult cr : addL)
//                scores.add(result.dCalendar.getSerial(cr.rMatch.getMatchDate()));
//            add("26", scores.toArray(), new String[]{""}, true);
//        }catch(Exception ex){add("26", ""); System.out.println("-26 " + ex);}

        try{
            scores.clear();
            for(NResult cr : addL)
                scores.add(result.aResult.calander.getMonitors(cr.rMatch.getMatchDate())[0] +
                " " + result.aResult.calander.getMonitors(cr.rMatch.getMatchDate())[1]);
            add("27", scores.toArray());
        }catch(Exception ex){add("27", ""); System.out.println("-27 " + ex);}

        try{
            scores.clear();
            for(NResult cr : addL)
                scores.add(result.dCalendar.getMonitors(cr.rMatch.getMatchDate())[0] +
                " " + result.dCalendar.getMonitors(cr.rMatch.getMatchDate())[1]);
            add("28", scores.toArray());
        }catch(Exception ex){add("28", ""); System.out.println("-28 " + ex);}

        try{
            add("29A", result.addResult.get(0).rMatch.getScores());
        }catch(Exception ex){add("29A", ""); System.out.println("-29A " + ex);}

        try{
            add("30", result.addResult.get(0).rMatch);
        }catch(Exception ex){add("30", ""); System.out.println("-30 " + ex);}

//        try{
//            add("31A", Utility.f_subract(result.addResult.get(0).rMatch, result));
//        }catch(Exception ex){add("31A", ""); System.out.println("-31A " + ex);}
//
//        try{
//            add("31B", Utility.f_subract(result.addResult.get(0).rMatch, result));
//        }catch(Exception ex){add("31B", ""); System.out.println("-31B " + ex);}
//
//        try{
//            add("31C", Utility.f_subract(result.addResult.get(0).rMatch, result));
//        }catch(Exception ex){add("31C", ""); System.out.println("-31C " + ex);}
//
//        try{
//            add("31D", Utility.f_subract(result.addResult.get(0).rMatch, result));
//        }catch(Exception ex){add("31D", ""); System.out.println("-31D " + ex);}

        try{
            add("32", result.addResult.get(0).number);
        }catch(Exception ex){add("32", ""); System.out.println("-32 " + ex);}

        try{
            add("33", result.addResult.get(0).rMatch.getMatchDate());
        }catch(Exception ex){add("33", ""); System.out.println("-33 " + ex);}

//        try{
//            add("34", result.addResult.get(0).row.get(0));
//        }catch(Exception ex){add("34", ""); System.out.println("-34 " + ex);}

//        try{
//            add("35", result.addResult.get(0).row.get(0));
//        }catch(Exception ex){add("35", ""); System.out.println("-35 " + ex);}

        try{
            add("36", result.addResult.get(0).row.subList(2, 4).toArray(), new String[]{"A","B"});
        }catch(Exception ex){add("36", ""); System.out.println("-36 " + ex);}

        try{
            add("37", result.addResult.get(0).row.subList(2, 4).toArray(), new String[]{"A","B"});
        }catch(Exception ex){add("37", ""); System.out.println("-37 " + ex);}

        try{
            add("38", result.addResult.get(0).rMatch.getScores());
        }catch(Exception ex){add("38", ""); System.out.println("-38 " + ex);}

        try{
            add("39", result.addResult.get(0).rMatch);
        }catch(Exception ex){add("39", ""); System.out.println("-39 " + ex);}

//        try{
//            add("40A", Utility.f_subract(result.addResult.get(0).rMatch, result));
//        }catch(Exception ex){add("40A", ""); System.out.println("-40A " + ex);}
//
//        try{
//            add("40B", Utility.f_subract(result.addResult.get(0).rMatch, result));
//        }catch(Exception ex){add("40B", ""); System.out.println("-40B " + ex);}
//
//        try{
//            add("40C", Utility.f_subract(result.addResult.get(0).rMatch, result));
//        }catch(Exception ex){add("40C", ""); System.out.println("-40C " + ex);}
//
//        try{
//            add("40D", Utility.f_subract(result.addResult.get(0).rMatch, result));
//        }catch(Exception ex){add("40C", ""); System.out.println("-40C " + ex);}

        try{
            add("41", result.aResult.rmatch.getScores());
        }catch(Exception ex){add("41","");System.out.println("-41 " + ex);}

        try{
            add("42", result.aResult.rmatch);
        }catch(Exception ex){add("42","");System.out.println("-42 " + ex);}

//        try{
//            add("43", result.aResult.cResultRow.get(0));
//        }catch(Exception ex){add("43","");System.out.println("-43 " + ex);}
//
//        try{
//            add("44", result.aResult.cDefaultRow.get(0));
//        }catch(Exception ex){add("44","");System.out.println("-44 " + ex);}

        try{
            add("45A", result.bResult.crange.range());
        }catch(Exception ex){add("45A","");System.out.println("-45A " + ex);}

        try{
            add("45B", result.bResult.crange.getName());
        }catch(Exception ex){add("45B","");System.out.println("-45B " + ex);}

        try{
            add("46", result.aResult.cResultRow.subList(2, 4).toArray(), new String[]{"A", "B"});
        }catch(Exception ex){add("46","");System.out.println("-46 " + ex);}

        try{
            add("47", result.aResult.cDefaultRow.subList(2, 4).toArray(), new String[]{"A", "B"});
        }catch(Exception ex){add("47","");System.out.println("-47 " + ex);}

        try{
            add("48", result.bResult.rmatch.getScores());
        }catch(Exception ex){add("48","");System.out.println("-48 " + ex);}

//        try{
//            add("49A", Utility.f_subract(result.aResult.pmatch, result));
//        }catch(Exception ex){add("49A", ""); System.out.println("-49A " + ex);}
//
//        try{
//            add("49B", Utility.f_subract(result.aResult.pmatch, result));
//        }catch(Exception ex){add("49B", ""); System.out.println("-49B " + ex);}

        try{
            add("49C", Utility.f_subract(result.aResult.pmatch, result));
        }catch(Exception ex){add("49C", ""); System.out.println("-49C " + ex);}

        try{
            add("49D", Utility.f_subract(result.aResult.pmatch, result));
        }catch(Exception ex){add("49D", ""); System.out.println("-49D " + ex);}

//        try{
//            add("49E", Utility.f_subract(result.aResult.pmatch, result));
//        }catch(Exception ex){add("49E", ""); System.out.println("-49E " + ex);}
//
//        try{
//            add("49F", Utility.f_subract(result.aResult.pmatch, result));
//        }catch(Exception ex){add("49F", ""); System.out.println("-49F " + ex);}

//        try{
//            add("50A", result.cMatch.getFixture());
//        }catch(Exception ex){add("50A","");System.out.println("-50A " + ex);}
//
//        try{
//            add("50B", result.aResult.cmResultRow.subList(2, 4).toArray(), new String[]{"A", "B"});
//        }catch(Exception ex){add("50B","");System.out.println("-50B " + ex);}

        try{
            add("51", result.cMatch);
        }catch(Exception ex){add("51","");System.out.println("-51 " + ex);}

        try{
            String status = (result.aResult.pmatch.getFixture() == result.cMatch.getFixture())
                ? "same" : "not same";
            add("52", status);
        }catch(Exception ex){add("52","");System.out.println("-52 " + ex);}

        try{
            add("53", result.cMatch.getMatchDate());
        }catch(Exception ex){add("53","");System.out.println("-53 " + ex);}
//
//        try{
//            add("54", result.aResult.cmResultRow.get(0));
//        }catch(Exception ex){add("54","");System.out.println("-54 " + ex);}
//
//        try{
//            add("55", result.aResult.cmDefaultRow.get(0));
//        }catch(Exception ex){add("55","");System.out.println("-55 " + ex);}

        try{
            add("56", result.aResult.cmResultRow.subList(2, 4).toArray(), new String[]{"A", "B"});
        }catch(Exception ex){add("56","");System.out.println("-56 " + ex);}

        try{
            add("57", result.aResult.cmDefaultRow.subList(2, 4).toArray(), new String[]{"A", "B"});
        }catch(Exception ex){add("57","");System.out.println("-57 " + ex);}

//        try{
//            add("58A", Utility.f_subract(result.cMatch, result));
//        }catch(Exception ex){add("58A", ""); System.out.println("-58A " + ex);}
//
//        try{
//            add("58B", Utility.f_subract(result.cMatch, result));
//        }catch(Exception ex){add("58B", ""); System.out.println("-58B " + ex);}
//
//        try{
//            add("58C", Utility.f_subract(result.cMatch, result));
//        }catch(Exception ex){add("58C", ""); System.out.println("-58C " + ex);}
//
//        try{
//            add("58D", Utility.f_subract(result.cMatch, result));
//        }catch(Exception ex){add("58D", ""); System.out.println("-58D " + ex);}
//
//        try{
//            add("58E", Utility.f_subract(result.cMatch, result));
//        }catch(Exception ex){add("58E", ""); System.out.println("-58E " + ex);}
//
//        try{
//            add("58F", Utility.f_subract(result.cMatch, result));
//        }catch(Exception ex){add("58F", ""); System.out.println("-58F " + ex);}

        try{
            add("59", result.bResult.rmatch.getFixture());
        }catch(Exception ex){add("59","");System.out.println("-59 " + ex);}

        try{
            add("60", result.bResult.rmatch);
        }catch(Exception ex){add("60","");System.out.println("-60 " + ex);}

        try{
            add("61", result.bResult.rmatch.getMatchDate());
        }catch(Exception ex){add("61","");System.out.println("-61 " + ex);}

//        try{
//            add("62A", result.bResult.resultRow.get(0));
//        }catch(Exception ex){add("62A","");System.out.println("-62A " + ex);}
//
//        try{
//            add("62B", result.bResult.rmatch.getMatchDate());
//        }catch(Exception ex){add("62B","");System.out.println("-62B " + ex);}
//
//        try{
//            add("62C", result.bResult.rmatch.getMatchDate());
//        }catch(Exception ex){add("62C","");System.out.println("-62C " + ex);}
//
//        try{
//            add("62D", Utility.f_subract(result.bResult.rmatch, result));
//        }catch(Exception ex){add("62D","");System.out.println("-62D " + ex);}
//
//        try{
//            add("62E", Utility.f_subract(result.bResult.rmatch, result));
//        }catch(Exception ex){add("62E","");System.out.println("-62E " + ex);}
//
//        try{
//            add("63", result.bResult.defaultRow.get(0));
//        }catch(Exception ex){add("63","");System.out.println("-63 " + ex);}

        try{
            add("64A", result.bResult.rmatch.getFixture());
        }catch(Exception ex){add("64A","");System.out.println("-64A " + ex);}

//        try{
//            add("64B", result.bResult.resultRow.subList(2, 4).toArray(), new String[]{"A", "B"});
//        }catch(Exception ex){add("64B","");System.out.println("-64B " + ex);}

        try{
            add("65", result.bResult.resultRow.subList(2, 4).toArray(), new String[]{"A", "B"});
        }catch(Exception ex){add("65","");System.out.println("-65 " + ex);}

        try{
            add("66", result.bResult.defaultRow.subList(2, 4).toArray(), new String[]{"A", "B"});
        }catch(Exception ex){add("66","");System.out.println("-66 " + ex);}

//        try{
//            add("67A", result.bResult.rmatch.getFixture());
//        }catch(Exception ex){add("67A","");System.out.println("-67A " + ex);}
//
//        try{
//            add("67B", Utility.f_subract(result.bResult.rmatch, result));
//        }catch(Exception ex){add("67B","");System.out.println("-67B " + ex);}
//
//        try{
//            add("67C", Utility.f_subract(result.bResult.rmatch, result));
//        }catch(Exception ex){add("67C","");System.out.println("-67C " + ex);}

//        try{
//            add("68", result.bResult.rowMatching.colVal.keySet().toArray());
//        }catch(Exception ex){add("68","");System.out.println("-68 " + ex);}

//        try{
//            add("69", result.bResult.rowMatching.colVal.values().toArray());
//        }catch(Exception ex){add("69","");System.out.println("-69 " + ex);}
//
        try{
            add("70", result.bResult.rowMatching.colVal.size());
        }catch(Exception ex){add("70","");System.out.println("-70 " + ex);}

        try{
            add("71", result.bResult.pmatch.getScores());
        }catch(Exception ex){add("71","");System.out.println("-71 " + ex);}

        try{
            add("72", result.bResult.pmatch);
        }catch(Exception ex){add("72","");System.out.println("-72 " + ex);}

        try{
            add("73A", result.bResult.pmatch.getMatchDate());
        }catch(Exception ex){add("73A","");System.out.println("-73A " + ex);}

        try{
            add("73B", result.bResult.brange.range());
        }catch(Exception ex){add("","");System.out.println("-73B " + ex);}

//        try{
//            add("74", result.aResult.calander.getSerial(result.bResult.pmatch.getMatchDate()));
//        }catch(Exception ex){add("74","");System.out.println("-74 " + ex);}
//
//        try{
//            add("75", result.dCalendar.getSerial(result.bResult.pmatch.getMatchDate()));
//        }catch(Exception ex){add("75","");System.out.println("-75 " + ex);}

        try{
            add("76", result.aResult.calander.getMonitors(result.bResult.pmatch.getMatchDate()),
                    new String[]{"A", "B"});
        }catch(Exception ex){add("76","");System.out.println("-76 " + ex);}

        try{
            add("77", result.aResult.calander.getMonitors(result.bResult.pmatch.getMatchDate()),
                    new String[]{"A", "B"});
        }catch(Exception ex){add("77","");System.out.println("-77 " + ex);}

//        try{
//            add("78A", Utility.f_subract(result.bResult.pmatch, result));
//        }catch(Exception ex){add("78A","");System.out.println("-78A " + ex);}
//
//        try{
//            add("78B", Utility.f_subract(result.bResult.pmatch, result));
//        }catch(Exception ex){add("78B","");System.out.println("-78B " + ex);}

        try{
            add("79", result.minusResult.get(0).number);
        }catch(Exception ex){add("79", ""); System.out.println("-79 " + ex);}

        try{
            add("80", result.minusResult.get(0).rMatch.getMatchDate());
        }catch(Exception ex){add("80", ""); System.out.println("-80 " + ex);}

//        try{
//            add("81", result.minusResult.get(0).row.get(0));
//        }catch(Exception ex){add("81", ""); System.out.println("-81 " + ex);}
//
//        try{
//            add("82", result.minusResult.get(0).row.get(0));
//        }catch(Exception ex){add("82", ""); System.out.println("-82 " + ex);}

        try{
            add("83", result.minusResult.get(0).row.subList(2, 4).toArray(), new String[]{"A","B"});
        }catch(Exception ex){add("83", ""); System.out.println("-83 " + ex);}

        try{
            add("84", result.minusResult.get(0).row.subList(2, 4).toArray(), new String[]{"A","B"});
        }catch(Exception ex){add("84", ""); System.out.println("-84 " + ex);}

        try{
            add("85", result.minusResult.get(0).rMatch.getScores());
        }catch(Exception ex){add("85", ""); System.out.println("-85 " + ex);}

        try{
            add("86", result.minusResult.get(0).rMatch);
        }catch(Exception ex){add("86", ""); System.out.println("-86 " + ex);}

//        try{
//            add("87A", Utility.f_subract(result.minusResult.get(0).rMatch, result));
//        }catch(Exception ex){add("87A", ""); System.out.println("-87A " + ex);}
//
//        try{
//            add("87B", Utility.f_subract(result.minusResult.get(0).rMatch, result));
//        }catch(Exception ex){add("87B", ""); System.out.println("-87B " + ex);}

        try{
            add("88", result.minusResult.get(0).number);
        }catch(Exception ex){add("88", ""); System.out.println("-88 " + ex);}

        try{
            add("89", result.minusResult.get(0).rMatch.getMatchDate());
        }catch(Exception ex){add("89", ""); System.out.println("-89 " + ex);}

//        try{
//            add("90", result.minusResult.get(0).row.get(0));
//        }catch(Exception ex){add("90", ""); System.out.println("-90 " + ex);}
//
//        try{
//            add("91", result.minusResult.get(0).row.get(0));
//        }catch(Exception ex){add("91", ""); System.out.println("-91 " + ex);}

        try{
            add("92", result.minusResult.get(0).row.subList(2, 4).toArray(), new String[]{"A","B"});
        }catch(Exception ex){add("92", ""); System.out.println("-92 " + ex);}

        try{
            add("93", result.minusResult.get(0).row.subList(2, 4).toArray(), new String[]{"A","B"});
        }catch(Exception ex){add("93", ""); System.out.println("-93 " + ex);}

        try{
            add("94", result.minusResult.get(0).rMatch.getScores());
        }catch(Exception ex){add("94", ""); System.out.println("-94 " + ex);}

        try{
            add("95", result.minusResult.get(0).rMatch);
        }catch(Exception ex){add("95", ""); System.out.println("-95 " + ex);}

//        try{
//            add("96A", Utility.f_subract(result.minusResult.get(0).rMatch, result));
//        }catch(Exception ex){add("96A", ""); System.out.println("-96A " + ex);}
//
//        try{
//            add("96B", Utility.f_subract(result.minusResult.get(0).rMatch, result));
//        }catch(Exception ex){add("96B", ""); System.out.println("-96B " + ex);}
//
//        try{
//            add("97A", result.bResult.pmatch.getFixture());
//        }catch(Exception ex){add("97A","");System.out.println("-97A " + ex);}
//
//        try{
//            add("97B", result.aResult.calander.getMonitors(result.bResult.pmatch.getMatchDate()),
//                    new String[]{"A", "B"});
//        }catch(Exception ex){add("97B","");System.out.println("-97B " + ex);}

        try{
            add("98", result.bResult.pmatch.getScores());
        }catch(Exception ex){add("98","");System.out.println("-98 " + ex);}

        try{
            add("99", result.bResult.pmatch);
        }catch(Exception ex){add("99","");System.out.println("-99 " + ex);}

//        try{
//            add("100", result.bResult.pmatch.getMatchDate());
//        }catch(Exception ex){add("100","");System.out.println("-100 " + ex);}
//
//        try{
//            add("101", result.aResult.calander.getSerial(result.bResult.pmatch.getMatchDate()));
//        }catch(Exception ex){add("101","");System.out.println("-101 " + ex);}
//
//        try{
//            add("102", result.dCalendar.getSerial(result.bResult.pmatch.getMatchDate()));
//        }catch(Exception ex){add("102","");System.out.println("-102 " + ex);}

        try{
            add("103", result.aResult.calander.getMonitors(result.bResult.pmatch.getMatchDate()),
                    new String[]{"A", "B"});
        }catch(Exception ex){add("103","");System.out.println("-103 " + ex);}

        try{
            add("104", result.dCalendar.getMonitors(result.bResult.pmatch.getMatchDate()),
                    new String[]{"A", "B"});
        }catch(Exception ex){add("104","");System.out.println("-104 " + ex);}

//        try{
//            add("105A", Utility.f_subract(result.bResult.pmatch, result));
//        }catch(Exception ex){add("105A","");System.out.println("-105A " + ex);}
//
//        try{
//            add("105B", Utility.f_subract(result.bResult.pmatch, result));
//        }catch(Exception ex){add("105B","");System.out.println("-105B " + ex);}

        try{
            add("106", result.bResult.sDirection);
        }catch(Exception ex){add("106","");System.out.println("-106 " + ex);}

        try{
            add("107", result.bResult.sLocation);
        }catch(Exception ex){add("107","");System.out.println("-107 " + ex);}

        try{
            add("108", (result.aResult.rowMatching.colVal.size() +
                    result.bResult.rowMatching.colVal.size()));
        }catch(Exception ex){add("108","");System.out.println("-108 " + ex);}

        try{
            add("109A", result.aResult.calander.getNumber());
        }catch(Exception ex){add("109A","");System.out.println("-109A " + ex);}

        try{
            add("109B", result.aResult.calander.getName());
        }catch(Exception ex){add("109B","");System.out.println("-109B " + ex);}

        try{
            add("110", result.aResult.calander.findRow(result.aResult.rmatch.getMatchDate()) -
                    result.aResult.calander.findRow(result.bResult.rmatch.getMatchDate()));
        }catch(Exception ex){add("110","");System.out.println("-110 " + ex);}

//        try{
//            add("111", result.aResult.calander.getMonitors(result.bResult.rmatch.getMatchDate()),
//                    new String[]{"A", "B"});
//        }catch(Exception ex){add("111","");System.out.println("-111 " + ex);}

        try{
            add("112", result.refNo);
        }catch(Exception ex){add("112", ""); System.out.println("-112 " + ex);}

        try{
            add("113", "Bag 1");
        }catch(Exception ex){add("113", ""); System.out.println("-113 " + ex);}


//        try{
//            add("999", new Object[]{3, 3, 76, 8, 65, 45, 45, 7, 54, 55, 5, 96, 22, 87},
//                    new String[]{"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M"});
//        }catch(Exception ex){add("111","");System.out.println("-111 " + ex);}
 

    }



    private void add(String col, Object data ){
        if(rowNumber == 0)
            dtm.addColumn(col);
        int cc = dtm.findColumn(col);
        dtm.setValueAt(data, rowNumber, cc);
        columnList.add(new RatedColumn(col, dtm.getColumnCount()));
//        dtm.addColumn(col, new Object[]{data});
    }

//    private void add(String col, String data ){
//        dtm.addColumn(col, new Object[]{data});
//    }

    private void add(String col, Object [] data){
        if(rowNumber == 0)
            dtm.addColumn(col);
        int cc = dtm.findColumn(col);
        dtm.setValueAt(data, rowNumber, cc);
        cList.add(cc);
        columnList.add(new RatedColumn(col, dtm.getColumnCount()));
    }

    private void add(String col, Object [] data, String [] colNames){
        if(rowNumber == 0)
            dtm.addColumn(col);
        DefaultTableModel tm = new DefaultTableModel(0, colNames.length);
        tm.addRow(colNames);
        tm.addRow(data);
        int cc = dtm.findColumn(col);
        dtm.setValueAt(tm, rowNumber, cc);
        hcList.add(cc);
        columnList.add(new RatedColumn(col, dtm.getColumnCount()));
    }

//    private void add(String col, Object [] data, String [] colNames, boolean multi){
//        if(rowNumber == 0)
//            dtm.addColumn(col);
//        DefaultTableModel tm = new DefaultTableModel(0, colNames.length);
//        tm.addRow(colNames);
//        if(multi){
//            for(Object ob : data)
//                tm.addRow(new Object[]{ob});
//        }else{
//            tm.addRow(data);
//        }
//        int cc = dtm.findColumn(col);
//        dtm.setValueAt(tm, rowNumber, cc);
//        hcList.add(cc);
//        columnList.add(new RatedColumn(col, dtm.getColumnCount()));
//    }

    public ArrayList<RatedColumn> getColumns(){
        if(columnList.isEmpty())
            fillData();
        return columnList;
    }

    public DefaultTableModel getData(){
        return dtm;
    }
}
